package com.blindBox.front.controller.register;

import com.blindBox.front.commonResult.MsgBackToFront;
import com.blindBox.front.handler.loginHandler.loginHandlerImpl.LoginByEamilHandler;
import com.blindBox.front.handler.registerHandler.AbstractRegisterHandler;
import com.blindBox.front.handler.registerHandler.registerHandlerImpl.AccountRegisterHandler;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

//用户注册控制层
@RestController
public class UserRegisterController
{
     @Resource(name="accountRegisterHandler")
     private AbstractRegisterHandler accountRegisterHandler;
    //用户注册
    @PostMapping("/u_register")
    public MsgBackToFront uRegister(@RequestParam("uname")String uname,
                                    @RequestParam("upwd")String upwd,
                                    @RequestParam("virtualImgs")String virtualImgs,
                                    @RequestParam("sex")Integer sex,
                                    @RequestParam("mail")String mail,
                                    @RequestParam("code")String code)
    {
        AccountRegisterHandler accountRegisterHandler = (AccountRegisterHandler) this.accountRegisterHandler;
        return accountRegisterHandler.autowiredUser(uname,upwd,virtualImgs,sex,mail,code).register();
    }

    //发送验证码
    @PostMapping("/u_register_code")
    public MsgBackToFront uLoginByEamil(@RequestParam("email")String email)
    {
        AccountRegisterHandler accountRegisterHandler = (AccountRegisterHandler) this.accountRegisterHandler;
        return accountRegisterHandler.sendCode(email);
    }
}
